import React, { Component } from 'react';
import { observer } from 'mobx-react';
import store from './store';

@observer
class ObserverText extends Component {

  componentDidMount() {
    this.timer = setInterval(() => {
      store.counter++;
    }, 1000)
  }

  componentWillUnmount() {
    clearInterval(this.timer);
    this.timer = null;
  }

  render() {
    return (
      <div>
        <p>ObserverText 组件 Count: {store.counter}</p>
      </div>
    )
  }
}

export default ObserverText;